package com.system.forum.controller;

import com.system.forum.common.AppResult;
import com.system.forum.exception.ApplicationException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//表示返回的结果都是数据，不是url
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }

    @GetMapping("/helloByName")
    public String helloByName(String name) {
        return "hello "+ name;
    }


    @GetMapping("/exception")
    public AppResult testException() throws Exception{
        throw new Exception("这是一个Exception。。。");
    }

    @GetMapping("/appException")
    public AppResult testApplicationException() {
        throw new ApplicationException("这是一个ApplicationException");
    }
}
